package com.jianz.campus_markets.controller;


import com.jianz.campus_markets.domain.ResponseResult;
import com.jianz.campus_markets.domain.dto.ProductCommentDto;
import com.jianz.campus_markets.domain.dto.UserChatDto;
import com.jianz.campus_markets.domain.entity.Collection;
import com.jianz.campus_markets.domain.entity.Comment;
import com.jianz.campus_markets.service.CollectionService;
import com.jianz.campus_markets.service.CommentService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author jianz
 * @since 2023-12-28
 */
@RestController
@RequestMapping("/comment")
public class CommentController {

    @Autowired
    private CommentService commentService;

    @PostMapping("/addComment")
    public ResponseResult addProductComment(@RequestBody ProductCommentDto productCommentDto) {

        return commentService.addProductComment(productCommentDto);
    }

    @PostMapping("/addChat")
    public ResponseResult addChat(@RequestBody UserChatDto userChatDto) {

        return commentService.addUserChat(userChatDto);
    }

    @GetMapping("/getComment")
    public ResponseResult getComment(int productId) {

        return commentService.getComment(productId);
    }

    @GetMapping("/getChat")
    @ApiOperation(value = "获取给别人发的信息")
    public ResponseResult getChat(int userId) {

        return commentService.getChat(userId);
    }

    @GetMapping("/getToChat")
    @ApiOperation(value = "获取别人发给我的信息")
    public ResponseResult getToChat(int toCommentUserId) {

        return commentService.getToChat(toCommentUserId);
    }

}

